import { FormConfig } from '@/components'
import { Row } from '@/components/FTable/components/search'
import { configCurryFilter } from '@/dictionaries/filter'
import { isTrue } from '@/utils/tools'
import dayjs from 'dayjs'
import { shallowRef } from 'vue'
/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-02-23 14:41:28
 */

export const columns: F.TableColumns[] = [
	{
		title: 'id',
		key: 'id',
		dataIndex: 'id',
		align: 'center',
		width: 60,
	},
	{
		title: '图片',
		key: 'img',
		dataIndex: 'img',
		align: 'center',
		width: 200,
		customRender: ({ record }: F.RableSlotScope<defs.server.BannerEntity>) => (
			isTrue(record.img) ? <a-image
				width={40}
				src={record.img}
			/> : '-'
		)
	},
	{
		title: '跳转类型',
		key: 'jumpType',
		dataIndex: 'jumpType',
		align: 'center',
		customRender: configCurryFilter('jumpType'),
		width: 120,
	},
	{
		title: '语言',
		key: 'lang',
		dataIndex: 'lang',
		align: 'center',
		width: 120,
		customRender: configCurryFilter('lang'),
	},
	{
		title: '跳转链接',
		key: 'url',
		dataIndex: 'url',
		align: 'center',
		width: 120,
	},
	{
		title: '排序',
		key: 'sort',
		dataIndex: 'sort',
		align: 'center',
		width: 120,
	},
	{
		title: '是否显示',
		key: 'status',
		dataIndex: 'status',
		align: 'center',
		customRender: configCurryFilter('status'),
		width: 120,
	},
	{
		title: '备注',
		key: 'remarks',
		dataIndex: 'remarks',
		align: 'center',
		width: 200,
	},
	{
		title: '创建时间',
		key: 'createDate',
		dataIndex: 'createDate',
		align: 'center',
		customRender: ({ record }: F.RableSlotScope<defs.server.BannerEntity>) => dayjs(record.createDate).format('YYYY-MM-DD HH:mm:ss'),
		width: 180
	},
	{
		title: '更新时间',
		key: 'updateDate',
		dataIndex: 'updateDate',
		align: 'center',
		customRender: ({ record }: F.RableSlotScope<defs.server.BannerEntity>) => dayjs(record.updateDate).format('YYYY-MM-DD HH:mm:ss'),
		width: 180
	},
	{
		title: '操作',
		dataIndex: 'action',
		key: 'action',
		align: 'center',
		slots: {
			customRender: 'actionRender',
		},
		width: 300,
		fixed: 'right',
	},
]
export const rows: Array<Row> = [
	{
		title: '是否显示',
		key: 'status',
		component: shallowRef(FormConfig),
		props: {
			prop: 'status'
		}
	},
	{
		title: '跳转类型',
		key: 'jumpType',
		component: shallowRef(FormConfig),
		props: {
			prop: 'jumpType'
		}
	},
]
